<template>
  <div class="product-list">
    <h2>商品列表</h2>
    
    <ul>
      <li v-for="product in products" :key="product.id">
        {{ product.name }} - ￥{{ product.price }}
        <button @click="addToCart(product)">加入购物车</button>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'ProductList',
  data() {
    return {
      products: [
        { id: 1, name: '商品A', price: 99 },
        { id: 2, name: '商品B', price: 199 },
        { id: 3, name: '商品C', price: 299 }
      ]
    }
  },
  methods: {
    addToCart(product) {
      this.$store.dispatch('addToCart', product)
    }
  }
}
</script>